package com.cyh.testscrollviewrecyclerview.test1;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.cyh.testscrollviewrecyclerview.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 使用CustomeRecyclerView和RecyclerView是不一样的，前者是整体上下移动，后缀只移动列表部分
 *
 * */
public class FirstActivity extends AppCompatActivity {

    private FirstAdapter mFirstAdapter;
    private FirstAdapter mFirstAdapter2;

    CustomeRecyclerView mRecyclerView;
    CustomeRecyclerView mRecyclerView2;

    //RecyclerView mRecyclerView;
    //RecyclerView mRecyclerView2;

    List<String> mData = new ArrayList<>();
    List<String> mData2 = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);

        mRecyclerView = findViewById(R.id.recyclerView);
        mRecyclerView2 = findViewById(R.id.recyclerView2);

        for(int i = 0; i < 30; i++) {
            mData.add("第" + i + "个--------");
            mData2.add("--------第" + i + "个");
        }

        initRecyclerView();
    }

    private void initRecyclerView() {
        FullyLinearLayoutManager manager = new FullyLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        FullyLinearLayoutManager manager2 = new FullyLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        //WrapContentLinearLayoutManager manager = new WrapContentLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        //WrapContentLinearLayoutManager manager2 = new WrapContentLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mRecyclerView.setLayoutManager(manager);
        mRecyclerView2.setLayoutManager(manager2);

        mFirstAdapter = new FirstAdapter(mData);
        mFirstAdapter2 = new FirstAdapter(mData2);

        mRecyclerView.setItemAnimator( new DefaultItemAnimator());
        mRecyclerView2.setItemAnimator( new DefaultItemAnimator());

        mRecyclerView.setAdapter(mFirstAdapter);
        mRecyclerView2.setAdapter(mFirstAdapter2);

    }
}
